//
//  MantisLeftImgTableViewCell.m
//  NLProjectFrameworkDemo
//
//  Created by iosdeveloper on 2020/5/8.
//  Copyright © 2020 yj_zhang. All rights reserved.
//

#import "MantisLeftImgTableViewCell.h"

@interface MantisLeftImgTableViewCell ()



@end
@implementation MantisLeftImgTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpView];
    }
    return self;
}

-(void)setUpView{
    [super setUpView];
    self.contentLabel.hidden=YES;//隐藏基类里面的文字
    
    UIImageView*photoImgView =[UIImageView new];
    photoImgView.backgroundColor =KLineColor;
    self.photoImgView=photoImgView;
    photoImgView.contentMode=UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:photoImgView];
    CGSize bgSize =CGSizeMake(adaptWidth750(120*2), adaptWidth750(80*2));
    [photoImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.avaterView.mas_right).offset(adaptWidth750(20));
        make.top.equalTo(self.avaterView);
        make.size.mas_equalTo(bgSize);
    }];
    
    [self setThreeCorner:bgSize bgView:(UIView*)photoImgView];
    
       [self.errorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
              make.right.equalTo(photoImgView.mas_left).offset(-adaptWidth750(20));
              make.centerY.equalTo(photoImgView);
          }];
}


-(void)reloadCellModel:(MantisCellBaseModel *)data{
    [super reloadCellModel:data];
    MantisImageMessageCellData*newData=(MantisImageMessageCellData*)data;
    
    if (![newData.content containsString:@"<p>"]) {
        if ([newData.content containsString:@"src"]) {//从服务器拿下来的url
            NSString*imgUrl =newData.content;
            imgUrl=[NSString getNewImgurlFromurl:imgUrl];
            [self.photoImgView setImageWithURL:[NSURL URLWithString:imgUrl]placeholder:KdefaultAVater];

        }
    }
    
    
    
}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
